Skip to content

docs: stop presenting Threadripper 68+68=137 W as a correct RAPL sum - #1

Draft
Dmao233 wants to merge 9 commits into
masterfrom
cursor/fix-rapl-docs-double-count-622a
Draft

docs: stop presenting Threadripper 68+68=137 W as a correct RAPL sum#1
Dmao233 wants to merge 9 commits into
masterfrom
cursor/fix-rapl-docs-double-count-622a

Conversation

@Dmao233

@Dmao233 Dmao233 commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Description

docs/explanation/rapl.md showed the Threadripper 1950X teaser

package-0-die-0: 68 W | package-0-die-1: 68 W | CodeCarbon: 137 W

with no note that those two dies can report the same socket-wide RAPL counter. That line was easy to read as confirmed-correct behaviour. It is the double-count discussed in mlco2#1274 / mlco2#1276 / mlco2#1379: one meter read twice, so the CPU RAPL value is ~68 W, not 137 W.

This PR only annotates the docs. It does not implement Linux RAPL deduplication (that remains mlco2#1276).

Changes in docs/explanation/rapl.md:

  • Mark the 68 W + 68 W = 137 W teaser as the known over-count.
  • Note mirrored per-die packages next to the existing hierarchy double-count explanation.
  • Qualify the AMD bullets that told readers to sum every package-X-die-Y domain.
  • Distinguish the later Threadripper capture, which exposes a single package-0 (kernel-dependent).

Related Issue

Fixes mlco2#1392

Related: mlco2#1274, mlco2#1276, mlco2#1379

Motivation and Context

Readers were being taught that summing two identical 68 W die readings is the right RAPL result. Whatever lands in mlco2#1276, that example should not stay unannotated.

How Has This Been Tested?

Screenshots (if appropriate):

Not applicable (docs-only).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

AI Usage Disclosure

  • 🟥 AI-vibecoded: You cannot explain the logic. Car analogy : the car drive by itself, you are outside it and just tell it where to go.
  • 🟠 AI-generated: Car analogy : the car drive by itself, you are inside and give instructions.
  • ⭐ AI-assisted. Car analogy : you drive the car, AI help you find your way.
  • ♻️ No AI used. Car analogy : you drive the car.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the docs/how-to/contributing.md document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

This branch lives on the fork. To open the intended PR against upstream:

gh pr create --repo mlco2/codecarbon \
  --head Dmao233:cursor/fix-rapl-docs-double-count-622a \
  --base master \
  --title "docs: stop presenting Threadripper 68+68=137 W as a correct RAPL sum"
Open in Web Open in Cursor 

cursoragent and others added 9 commits August 30, 2026 16:04
rapl.md showed two Threadripper dies both reporting 68 W and
CodeCarbon totaling 137 W with no warning. Those package-*-die-*
domains can mirror one socket-wide counter (mlco2#1274); readers were
being taught that 137 W is the right RAPL reading.

Annotate the example as the known double-count, and qualify the AMD
bullets that told readers to sum every package-X-die-Y domain.

Refs mlco2#1392

Co-authored-by: CenFangyu <Dmao233@users.noreply.github.com>
The Windows EMI backend (mlco2#1263) and the Linux RAPL backend (mlco2#1276) both
need to detect channels that mirror the same hardware energy counter.
Move the tolerance constant and the matching/detection helpers from
windows_emi.py to rapl.py, next to RAPLFile, so both backends share one
definition instead of duplicating the 1e-6 magic number. No behavior
change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
start() used to permanently remove suspected mirrored counters from
self._rapl_files based on a single instantaneous comparison. A file
dropped by mistake (two independent packages coincidentally holding the
same counter value) was gone for the life of the tracker, and each new
start() of a task re-ran the destructive detection on whatever was left.

Flag suspected mirrors in a candidate map instead, exactly like the EMI
backend does: the files stay monitored, candidates are only left out of
the reported details, and every start() re-evaluates the detection from
the full set of files.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ropping

Port the second stage of the EMI mirrored-channel detection (mlco2#1263) that
the Linux side was missing: a counter flagged at start() is only dropped
for good once it has also accumulated the very same energy as its
reference over a measurement interval. A candidate whose delta diverges
is a real meter and is restored into the measurement; a candidate that
has not accumulated anything stays pending until an interval is
conclusive. This prevents a genuine second package from being silently
discarded for the life of the run because it coincidentally held the
same counter value at start.

Unlike EMI, which snapshots a device's channels atomically, the powercap
sysfs files are read one after the other, so two views of the same
counter differ by the energy accrued between the reads. A relative
tolerance alone misses true mirrors when the counters are small (right
after a wrap-around, which happens every few minutes on packages with a
small max_energy_range_uj). Matching therefore also allows an absolute
1 J difference, both when flagging candidates and when comparing deltas;
a wrongly flagged independent package is restored by the confirmation
stage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…unters-1274

fix: deduplicate mirrored Linux RAPL counters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: rapl.md presents the Threadripper 68+68 = 137 W sum as correct

3 participants